<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">{{data.title}}</block>
		</cu-custom>
		<view class="text-empty text-center" v-if="data.specials.length==0">
			<text>空空如也</text>
		</view>
		<view class="specials padding-sm" v-else>
			<view class="cu-card article bg-white">
				<view class="cu-item" @click="naviTo('special/detail',{id:item.id})" v-for="(item, index) in data.specials" :key="index">
					<view class="content">
						<image class="cover" :src="item.imgUrl" mode="aspectFill"></image>
						<view class="desc">
							<view class="title">{{item.title}}</view>
							<view class="text-content text-warp">{{item.subtitle}}</view>
							<view>
								<scorebar :score="item.score" size="sm"></scorebar>
							</view>
						</view>
					</view>
				</view>
			</view>
			<uni-load-more class="bg-white" :status="loadmore" :contentText="contentText"></uni-load-more>
		</view>
	</view>
</template>

<script>
	import core from "@/static/core.js"
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	import scorebar from "@/components/util/scorebar.vue"
	
	export default {
		components: {uniLoadMore, scorebar},
		data() {
			return {
				page:1,
				loadmore:'more',
				contentText:{
					"contentdown":"上滑加载更多数据",
					"contentrefresh":"加载中...",
					"contentnomore":"我是有底线的~"
				},
				data:{
					title:"专题栏目",
					specials:[]
				}
			}
		},
		onLoad() {
			this.loadSpecial(1);
			this.Sel();
		},
		onShow() {
			
		},
		onPullDownRefresh() {
			this.loadSpecial(1);
			uni.stopPullDownRefresh();
		},
		onReachBottom() {
			if(this.loadmore=='noMore') return false;
			return this.loadSpecial(this.page+1);
		},
		methods:{
			initData(route, data={}, callback=false){
				var that = this;
			// 	core.get(route,function(res){
			// 		if(typeof(res.message)!='undefined' && typeof(res.type)!='undefined'){
			// 			return core.report(res, true);
			// 		}
			// 		that.data = res;
			// 		uni.setNavigationBarTitle({
			// 			title:res.title
			// 		});
			// 		if(callback){
			// 			callback(res);
			// 		}
			// 	},data);
			},
			async Sel(){
				this.data.specials=(await this.$api.reqGet({
					url:"column/selsta",
				})).data;
				console.log(this.data.specials)
			},
			naviTo(page,data={}){
				return core.navito(page,data);
			},
			unSupport(){
				return core.toast('敬请期待');
			},
			loadSpecial(page=1){
				var that = this;
				return this.initData('special',{page:page},function(res){
					that.page = page;
					that.loadmore = res.specials.length<15 ? 'noMore' : 'more';
				});
			}
		}
	}
</script>

<style>
	page{background: #FFFFFF;}
</style>
